﻿@{
    ViewBag.Title = "酒店注册";
    Layout = "../Shared/_Login.cshtml";

   
}
@model RBS.Web.Hotel.Models.Hotel 

 
<script>
    var data;
    $(function () {
        //加载城市列表
    
        $("#submitImg").click(function () {
            if ($("#boy").val().length > 0) {
                ajaxFileUpload();
            }
            else {
                alert("请选择图片");
            }
        });
        $("#img1").hide();
    });
    function ajaxFileUpload() {
        $.ajaxFileUpload(
            {
                url: '@Url.Action("UploadImg")', //用于文件上传的服务器端请求地址
                secureuri: false, //一般设置为false
                fileElementId: 'boy', //文件上传空间的id属性  <input type="file" id="file" name="file" />
                dataType: 'HTML', //返回值类型 一般设置为json
                success: function (data, status)  //服务器成功响应处理函数
                {
                    //alert(data);
                    $("#img1").show();
                    $("#img1").attr("src", data);
                    $("#showimg").attr("href", data);
                    $("#Hotels_License").val(data);
                    if (typeof (data.error) != 'undefined') {
                        if (data.error != '') {
                            alert(data.error);
                        } else {
                            alert(data.msg);
                        }
                    }
                },
                error: function (data, status, e)//服务器响应失败处理函数
                {
                    alert(e);
                }
            }
        );
    }
    function weWantedTo() {
    }
  /*  function myFun(result) {
        var cityName = result.name;
        // alert("当前定位城市:" + cityName);
    }
    var myCity = new BMap.LocalCity();
    myCity.get(myFun);*/
</script>
@using (Ajax.BeginForm("Register", "Login", FormMethod.Post,new AjaxOptions()))
{ 
    <div class="hotelreg-form">
        @Html.ValidationSummary(true)
           <fieldset>
            <legend>酒店负责人信息</legend>
            <dl>
                <dt><b>*</b>手机号</dt>
                <dd>
                    @Html.TextBoxFor(model => model.HotelUsers.H_UID, new { @class = "input normal", datatype = "m", sucmsg = " ", ajaxurl = "../tools/hotelAjax.ashx?action=email_validate" })
                    <span class="Validform_checktip">将作为用户的登录名。</span>
                </dd>
            </dl>
            <dl>
                <dt><b>*</b>用户姓名</dt>
                <dd>
                    @Html.TextBoxFor(model => model.HotelUsers.H_UserName, new { @class = "input normal", datatype = "*2-6" })  <span class="Validform_checktip">请填写真实姓名。</span>
                </dd>
            </dl>
            <dl>
                <dt><b>*</b>登录密码</dt>
                <dd>
                    @Html.Password("Password", null, new { @class = "input normal", datatype = "*6-20", nullmsg = "请设置密码", errormsg = "密码范围在6-20位之间", sucmsg = " ", value = ViewBag.defaultpassword })

                    <span class="Validform_checktip">请输入登录密码。</span>
                </dd>
            </dl>
            <dl>
                <dt><b>*</b>确认密码</dt>
                <dd>
                    @Html.Password("ConfirmPassword", null, new { @class = "input normal", datatype = "*", recheck = "Password", nullmsg = "请再输入一次密码", errormsg = "两次输入的密码不一致", sucmsg = " ", value = ViewBag.defaultpassword })
                    <span class="Validform_checktip">请再次输入登录密码。</span>

                </dd>
            </dl>
        </fieldset>
        <fieldset>
            <legend>酒店信息</legend>
            <dl>
                <dt><b>*</b>酒店名称</dt>
                <dd>
                    @Html.TextBoxFor(model => model.Hotels.H_Name, null, new { @class = "input normal", datatype = "*2-20" })
                    <span class="Validform_checktip">酒店名称</span>
                </dd>
            </dl> 
            <dl>
                <dt><b>*</b>联系电话</dt>
                <dd>
                    @Html.TextBoxFor(model => model.Hotels.Telphone, null, new { @class = "input tel", datatype = @"/((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)/" })
                    <span class="Validform_checktip">联系电话！</span>
                </dd>
            </dl>
            <dl>
                <dt><b>*</b>酒店地址</dt>
                <dd>
              
                    @Html.Partial("_City")
                    @Html.TextBoxFor(model => model.Hotels.Address, null, new { @class = "input normal", onblur = "doOptions()" })<span class="Validform_checktip">酒店地址</span>
                    <br />
                    @Html.HiddenFor(model => model.Hotels.Location)
                     <div id="optionsNarrative" style="  margin-left:400px; margin-top: -250px; z-index: 1000;overflow:hidden ;position: absolute">鼠标点击确认详细信息</div>
                    <div id="allmap" style="width: 450px;height: 300px; margin-left:400px; margin-top: -250px; z-index: 999;overflow:hidden ;position: absolute">
                       
                    </div>

                </dd>
            </dl>
            <dl>
                <dt>营业执照</dt>
                <dd> 
                    @Html.HiddenFor(model => model.Hotels.License)
                    <input type="file" id="boy" name="boy" class="input normal upload-path" />
                    <input type="button" value="上传" id="submitImg" class="btn btn-default" />
                    <br />
                    <a id="showimg" title="点击图片查看大图" class="thickbox">
                        <img id="img1" alt="营业执照" width="300" />
                    </a>
                </dd>
            </dl>
        </fieldset> 
   
              <div class="editor-agreement">
				<input type="checkbox" checked="checked"/>
				我已经阅读并接收本网站协议<a href=#>用户协议</a>
			</div>
        <div class="reg-submit">
            <input id="btnSubmit" type="submit" value="注册" />
        </div>
       
        @Html.Hidden("Province")
        @Html.Hidden("City")
        @Html.Hidden("Region")
      
    </div>  
}

     
       
@*
<script>
    var SAMPLE_ADVANCED_POST = 'http://api.map.baidu.com/geocoder/v2/?ak=您的密钥&callback=renderOption&output=json';
    var advancedOptions = '';
    var address;
    function showOptionsURL(type) {
        advancedOptions = SAMPLE_ADVANCED_POST;
        address = document.getElementById('Hotels_Address').value;
        var cityname = document.getElementById('city2').value;
        // alert(cityname);
        advancedOptions += "&address=" + address;
        advancedOptions += "&city=" + cityname;
        var safe = advancedOptions;
        //  document.getElementById('optionsSampleUrl').innerHTML = safe.replace(/</g, '&lt;').replace(/>/g, '&gt;');
    };

    function renderOption(response) {
        var html = '';
        if (response.status) {
            var text = "无正确的返回结果:\n";
            document.getElementById('optionsNarrative').innerHTML = text;
            return;
        }
        var location = response.result.location;
        var uri = 'http://api.map.baidu.com/marker?location=' + location.lat + ',' + location.lng + '&title=' + response.result.level + '&content=' + address + '&output=html';
        var staticimageUrl = "http://api.map.baidu.com/staticimage?center=" + location.lng + ',' + location.lat + "&markers=" + location.lng + ',' + location.lat;
        html = '<p>坐标：纬度: ' + location.lat + "  经度: " + location.lng + '<br/>';
        html += '精度: ' + response.result.precise + '<br/>';
        html += '可信度: ' + response.result.confidence + '<br/>';
        html += '地址类型: ' + response.result.level + '</p>';
        html += '<p><img src="' + staticimageUrl + '"/></p>';
        html += '<p>分享该点: <a href="' + uri + '" target="_blank">' + uri + '</a></p>'; //将该链接设置成可单击
        // document.getElementById('optionsNarrative').innerHTML = html;
        $("#Hotels_Location").val(location.lng + "," + location.lat);
        $("#Province").val(document.getElementById('province').value);
        $("#City").val(document.getElementById('city1').value);
        $("#Region").val(document.getElementById('city2').value);
        return;
    } 
    function doOptions() {
        /*    var script = document.createElement('script');
        script.type = 'text/javascript';
        showOptionsURL('buttonClick');
        var newURL = advancedOptions.replace('您的密钥', '9hKFxXfINYjmgLFnKg4Mty0r');
        script.src = newURL;
        document.body.appendChild(script);*/
       
    };

</script>*@ 
 
<script type="text/javascript"> 
    // 百度地图API功能
    var map = new BMap.Map("allmap");
    var point = new BMap.Point(116.331398, 39.897445);
    map.centerAndZoom(point, 12);
    map.enableScrollWheelZoom();   //启用滚轮放大缩小，默认禁用
    map.enableContinuousZoom();     
      
    $(document).ready(function () { 
        $('#province').change(function () { 
            theLocation();
        });
        $('#city1').change(function () { 
            theLocation();
        });
        $('#city2').change(function() { 
            theLocation();
        });
    }); 
    function theLocation() {

        var city = $('#city2').children('option:selected').text();
        if (city != "") {
            map.centerAndZoom(city, 14); // 用城市名设置地图中心点
        } else {
            city = $('#city1').children('option:selected').text();
            map.centerAndZoom(city, 14);
        }
    }
    map.addEventListener("click",function(e){
       // alert(e.point.lng + "," + e.point.lat);
        $("#Hotels_Location").val(e.point.lng + "," + e.point.lat);
        theLocation2(e.point.lng, e.point.lat);
        var geoc = new BMap.Geocoder();
        //详细地址解析
        var pt = e.point;
        geoc.getLocation(pt, function (rs) {
            var addComp = rs.addressComponents; 
           /* $("#Province").val(document.getElementById('province').value);
            $("#City").val(document.getElementById('city1').value);
            $("#Region").val(document.getElementById('city2').value);*/
            $('#city2').children('option:selected').val(addComp.province);
            $("#Hotels_Address").val(addComp.province  + addComp.city + addComp.district + addComp.street + addComp.streetNumber);
           

            //  alert(addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber);
        });
    });
    function theLocation2(lng,lat) {
        if (lng != "" && lat != "") {
            map.clearOverlays();
            var newPoint = new BMap.Point(lng,lat);
            var marker = new BMap.Marker(newPoint);  // 创建标注
            map.addOverlay(marker);              // 将标注添加到地图中
            map.panTo(newPoint);
        }
    }
    function doOptions() {
        var address = document.getElementById('Hotels_Address').value;
        var cityname = document.getElementById('city2').value;
        // 创建地址解析器实例
        var myGeo = new BMap.Geocoder();
        // 将地址解析结果显示在地图上,并调整地图视野
        myGeo.getPoint(address, function (point) {
            if (point) {
                map.centerAndZoom(point, 18);
                map.addOverlay(new BMap.Marker(point));
                //alert(point.lng + "," + point.lat); 
                $("#Hotels_Location").val(point.lng + "," + point.lat);
                $("#Province").val(document.getElementById('province').value);
                $("#City").val(document.getElementById('city1').value);
                $("#Region").val(document.getElementById('city2').value);
            }
        }, cityname);

    };
</script>
